﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace WhackBL
{
    public class MyCommand : ICommand
    {
        Action<Object> execute;
       Func <bool> canex;
        public MyCommand(Action<Object> execute, Func<bool> canex = null ) 
        {
        this.execute = execute;
            this.canex = canex;
        }
        public event EventHandler? CanExecuteChanged;

        public bool CanExecute(object? parameter)
        {
            return canex?.Invoke() != false;
        }

        public void Execute(object? parameter)
        {
            execute?.Invoke(parameter);
        }
    }
}
